function [cor_pupil_pos]=correct_pupil_pos(pupil_pos,blinks,nbr_iframes)
tmp_pupil_pos=pupil_pos;

throw_away=[];
for vnd=1:length(nbr_iframes)-1
    throw_away(vnd)=sum(nbr_iframes(1:vnd));
end

for bnd=1:length(throw_away)
    init1=round(mean(tmp_pupil_pos(1,throw_away(bnd)-10:throw_away(bnd)-1)));
    init2=round(mean(tmp_pupil_pos(2,throw_away(bnd)-10:throw_away(bnd)-1)));
    tmp_pupil_pos(1,throw_away(bnd):throw_away(bnd)+2)=init1;
    tmp_pupil_pos(2,throw_away(bnd):throw_away(bnd)+2)=init2;
end

for ind=1:size(blinks,1)
    init_pos1=round(mean(tmp_pupil_pos(1,blinks(ind,1)-10:blinks(ind,1)-1)));
    init_pos2=round(mean(tmp_pupil_pos(2,blinks(ind,1)-10:blinks(ind,1)-1)));
    tmp_pupil_pos(1,blinks(ind,1)-1:blinks(ind,2)+1)=init_pos1;
    tmp_pupil_pos(2,blinks(ind,1)-1:blinks(ind,2)+1)=init_pos2;
end

cor_pupil_pos=tmp_pupil_pos;